﻿@{
    ViewBag.Title = "用户管理";
}
@model IEnumerable<User>

<div class="row">
    <div class="col-xs-12">
        <form asp-action="Index" method="get" class="form-inline">
            <input type="text" name="UserName" class="form-control" placeholder="昵称" />
            <input type="text" name="Email" class="form-control" placeholder="邮箱" />
            <input type="text" name="Mobile" class="form-control" placeholder="手机" />
            <button class="btn btn-primary" type="submit">搜索</button>
        </form>
    </div>
</div>
<hr />
<div class="row">
    <div class="col-xs-12">
        <table class="table table-hover">
            <tr>
                <th>Id</th>
                <th>昵称</th>
                <th>手机</th>
                <th>邮箱</th>
                <th>金币</th>
                <th>经验</th>
                <th>等级</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            @foreach (var item in Model)
            {
            <tr>
                <td>@item.Id</td>
                <td>@item.UserName</td>
                <td>@item.Mobile</td>
                <td>@item.Email</td>
                <td>@item.TradingPoints</td>
                <td>@item.ExpPoints/@item.ExpMaxPoints</td>
                <td>Lv.@item.Level</td>
                <td>@item.Status.GetDescription()</td>
                <td>
                    <a asp-action="Edit" class="text-sm" asp-route-id="@item.Id"><i class="fa fa-edit"></i></a>
                    <a href="javascript:resetPwd(@item.Id)"><i class="fa fa-lock"></i></a>
                </td>
            </tr>
            }
        </table>
    </div>
</div>
@section scripts{ 
    <script type="text/javascript">
        function resetPwd(id) {
            if (confirm('重置密码？')) {
                $.get('@Url.Action("ResetPwd","User")?userId=' + id, function (data) {
                    alert('密码重置为123456');
                })
            }
        }
    </script>
}